package com.woniu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.entity.SpenCategory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hyl
 * @since 2022-08-28
 * 为了方便理解，暂时不使用mybatis-plus的方法
 */
public interface SpenCategoryMapper extends BaseMapper<SpenCategory> {

    @Insert("insert into spen_category(cate_name) values(#{cateName})")
    void addSpenCategory(SpenCategory sc);

    @Update("update spen_category set cate_name=#{cateName} where cate_id=#{cateId}")
    void updateSpenCategory(SpenCategory sc);

    @Select("select * from spen_category where cate_id=#{cateId}")
    SpenCategory selectOneByCateId(Integer cateId);

    @Select("select * from spen_category where cate_name=#{cateName}")
    SpenCategory selectOneByCateName(String cateName);

    @Delete("delete from spen_category where cate_id=#{id}")
    void deleteOne(Integer id);
}
